/**
 * Created by Administrator on 2017/7/4.
 * ss
 */
(function(window){

    function Component(options){
        this.doc = document;
        this.options  = options || {};
        this.name = options["name"];
        this.icon = options["icon"] || Component[this.name].icon;
        this.caption = options["caption"] || Component[this.name].caption;
    }
    Component.prototype.getIcon = function(){
        return this.icon;
    }

    Component.prototype.getCaption = function(){
        return this.caption;
    }

    Component.prototype._addShadow = function(){
        var self = this;
        this.shadowDiv = this.doc.createElement("div");
        this.mainDom.appendChild(this.shadowDiv);
        this.shadowDiv.className = "green_shadow";
        this.shadowDiv.innerHTML= "<div><i class='"+XComponent[this.name].icon+"'></i><p>"+self.getCaption()+"</p></div>"
        $(this.mainDom).hover(function(){
            $(self.shadowDiv).show();
        },function(){
            $(self.shadowDiv).hide();
        });
    }

    Component.prototype.showComponentEditor = function(options){
        if(!this.componentEditor){
            this.componentEditor = new ComponentEditor[this.name](options);
        }
        this.componentEditor.show(options);
    }

    Component.extend = function(obj){
        var c  = obj.prototype.constructor
        obj.prototype = XComponent.prototype;
        obj.prototype.constructor = c;
    }


    window["XComponent"] = Component;
})(window);